package com.account.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Repository;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.account.dao.AccountDao;
import com.account.dto.AccountDto;
import com.account.service.AccountService;
import com.account.util.Pager;

@Service
@Transactional
@Repository("accountService")
public class AccountServiceImpl implements AccountService{
  
  @Resource
  private AccountDao accountDao;

  /**
   * 添加帐目信息
   * @param dto
   */
  @Override
  public Boolean addAccountInfo(AccountDto dto) {
    return accountDao.addAccountInfo(dto) > 0;
  }

  /**
   * 分页查询帐目信息列表信息
   * @param dto
   * @return
   */
  @Override
  public Pager<AccountDto> getAccountInfoList(AccountDto dto) {
    Long totalRecord = accountDao.getAccountInfoCount(dto);
    Pager<AccountDto> pager = null;
    if(totalRecord > 0){
      List<AccountDto> recordList = accountDao.getAccountInfoList(dto);
      pager = new Pager<AccountDto>(dto.getPageSize(), dto.getPageNumber(), totalRecord, recordList);
    }
    return pager;
  }

}
